package com.zhentao.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhentao.model.activity.dto.ActivityDto;
import com.zhentao.model.activity.pojo.AdActivity;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.service.AdActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/admin/activity")
@Api(tags = "ActivityController-后端活动管理")
public class ActivityController {

    @Resource
    AdActivityService adActivityService;

    /**
     * 后台活动列表
     * @param dto
     * @return
     */
    @ApiOperation("后台活动列表")
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ActivityDto dto){
        return adActivityService.getList(dto);
    }
    /**
     * app活动列表
     * @param dto
     * @return
     */
    @ApiOperation("app活动列表")
    @PostMapping("/appList")
    public ResponseResult appList(@RequestBody ActivityDto dto){
        return adActivityService.appList(dto);
    }

    /**
     * 活动添加
     * @param activity
     * @return
     */
    @ApiOperation(("后台活动添加"))
    @PostMapping("/add")
    public  ResponseResult add(@RequestBody AdActivity activity){
        return adActivityService.add(activity);
    }


    /**
     * 活动修改
     * @param activity
     * @return
     */
    @ApiOperation(("后台活动修改"))
    @PostMapping("/update")
    public  ResponseResult update(@RequestBody AdActivity activity){
        return adActivityService.updateActivity(activity);
    }
    /**
     * 活动状态调整
     * @param id
     * @return
     */
    @ApiOperation(("后台活动状态调整"))
    @PostMapping("/putway")
    public  ResponseResult putway(@RequestParam("id") int id ){
        return adActivityService.putway(id);
    }

    /**
     * 活动删除
     * @param id
     * @return
     */
    @PostMapping("/del")
    @ApiOperation(("活动硬删除"))
    public ResponseResult del(@RequestParam("id") Integer id){
        adActivityService.removeById(id);
        return ResponseResult.okResult("删除成功");
    }


    /**
     * 根据活动id查询活动
     * @param dto
     * @return
     */
    @PostMapping("/selectOne")
    @ApiOperation("根据活动id查询活动")
    public ResponseResult selectPersonByActivity(@RequestBody ActivityDto dto){
        return adActivityService.selectOne(dto);
    }
}
